<template>
  <div class="body">
    <van-nav-bar
      title="消息"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      
      <!-- 
        <van-cell v-for="item in list" :key="item" :title="item" />
       -->
      <div
        class="van-hairline--top-bottom"
        v-for="item in list"
        :key="item"
        style="height: 17vw;"
      >
      <!--
        <van-row type="flex">
          <van-col span="4">
            <van-image
              round
              width="16vw"
              height="16vw"
              src="http://q1.qlogo.cn/g?b=qq&nk=42964179&s=640"
              style="margin-left: 2vw;"
            />
          </van-col>
          <van-col span="2"></van-col>
          <van-col span="14">简略消息</van-col>
          <van-col span="4">时间</van-col>
        </van-row>
        -->
        <van-row type="flex" align="center">
          <van-col span="6" class="center">
            <van-image
              round
              width="12vw"
              height="12vw"
              src="http://q1.qlogo.cn/g?b=qq&nk=42964179&s=640"
              style="margin-left: 2.5vw; margin-top: 2.5vw; margin-bottom: 2.5vw;"
            />
          </van-col>
          <van-col span="14">
            <div class="van-ellipsis">{{ item }}这是一段最多显示一行的文字，多余的内容会被省略</div>
          </van-col>
          <van-col span="4">
            05/21
          </van-col>
        </van-row>
      </div>
    </van-list>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
    };
  },
  methods: {
    onClickLeft() {
      this.$router.push({ path: '/m/me' });
    },
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        // 一次加载5条
        for (let i = 0; i < 5; i++) {
          this.list.push(this.list.length + 1);
        }

        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (this.list.length >= 35) {
          this.finished = true;
        }
      }, 1000);
    },
  },
};
</script>

<style>
.body{
  font-size: 14px;
}
</style>
